package com.yue.yadmin.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.yue.yadmin.model.DataTablesModel;
import com.yue.yadmin.model.DataTablesModel.Field;
import com.yue.yadmin.model.SysExample;
import com.yue.yadmin.service.SysExampleService;
import com.yue.yadmin.service.SysMenuService;
import com.yue.yadmin.utils.Log;
import com.yue.yadmin.utils.SpringContextUtils;
@Controller
@RequestMapping("/example")
public class SysExampleController extends BaseController<SysExample> {
	@Autowired
	SysExampleService sysTestService;
	@RequestMapping("/velocity")
	public String voolBoxTest(){
		return "example/velocity";
	}
	@RequestMapping("/test")
	public ModelAndView test(Long id){
		Log.getLogger(this).info("id:{}",id);
		Log.getLogger(this).info("测试：{}",SpringContextUtils.getBean("sysMenuServiceImpl",SysMenuService.class).getList());
		ModelAndView modelAndView = new ModelAndView("example/test");
		modelAndView.addObject("id", id);
		modelAndView.addObject("sysTest", sysTestService.selectByPrimaryKey(id));
		return modelAndView;
	}
	@RequestMapping("/testDataTables")
	public String testDataTables(){
		return "example/testDataTables";
	}
	@RequestMapping("/testDataTables2")
	public ModelAndView testDataTables2(){
		ModelAndView modelAndView = new ModelAndView("example/testDataTables");
		modelAndView.addObject("dataTables",new DataTablesModel("/example", true, null)
			.addField(new Field("id", "ID", false, false, false, false, true,null))
			.addField(new Field("name", "名称", true, true, true, true, true,null))
			.addField(new Field("testName", "测试名称", true, true, true, true, true,null))
			.addField(new Field("createTime", "创建时间", true, true, true, true, true,"date"))
			);
		return modelAndView;
	}
}
